package homework03;

import java.util.Scanner;
import java.util.Arrays;

class Shape{
	final static double PI=3.14;
	static double sumA=0;
	static double sumP=0;
	
	
	
	
	
	
}

class Rectangle extends Shape{
	private int width;
	private int length;

	public double getPerimeter()
	{
		sumP+= (double)(width+length)*2;
		return (double)((width+length)*2);
		
	}
	
	public double getArea(){
		sumA+=(double)(width*length);
		return (double)(width*length);
	}
	
	
	public Rectangle(int width,int length){
		this.width=width;
		this.length=length;
	}
	
	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}

	public String toString() {
		return "Rectangle [width=" + width + ", length=" + length + "]";
	}
	
}

class Circle extends Shape{
	private int radius;	
	
	public Circle(int radius){
		this.radius=radius;
	}
	
	public double getPerimeter(){
		sumP+= radius*2*Shape.PI;
		return radius*2*Shape.PI;
	}
	
	public double getArea(){
		sumA+=Math.pow(radius,2)*Shape.PI;
		return Math.pow(radius,2)*Shape.PI;
	}

	
	public int getRadius() {
		return radius;
	}

	public void setRadius(int radius) {
		this.radius = radius;
	}

	public String toString() {
		return "Circle [radius=" + radius + "]";
	}
	
}



public class Seven04 {
	public static void main(String args[]) {
		Scanner sc= new Scanner(System.in);
		String n=sc.nextLine();
		String shape[]=new String[Integer.parseInt(n)];
		String clas[]=new String[Integer.parseInt(n)];
		for(int i=0;i<Integer.parseInt(n);i++){
			String str=new String();
			str = sc.next();
			switch (str){
			case "rect":
				Rectangle rect=new Rectangle(sc.nextInt(),sc.nextInt());
				
				rect.getArea();
				rect.getPerimeter();
				shape[i]=rect.toString();
				clas[i]=rect.getClass()+","+rect.getClass().getSuperclass();
				break;
				
			case "cir":
				Circle cir=new Circle(sc.nextInt());
				cir.getArea();
				cir.getPerimeter();
				shape[i]=cir.toString();
				clas[i]=cir.getClass()+","+cir.getClass().getSuperclass();
				break;
			}
		}
		System.out.println(Shape.sumP);
		System.out.println(Shape.sumA);
		System.out.println(Arrays.deepToString(shape));
		for(int i=0;i<Integer.parseInt(n);i++){
			System.out.println(clas[i]);
		}

		
	}
}

